﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Editor
{
    class EditorLoadingState : Game.GameLoadingState
    {
        public EditorLoadingState(Game.DataBase.Manager DataBaseManager)
            : base(DataBaseManager)
        {
        }

        public Game.Observer CameraObserver
        {
            get;
            set;
        }

        protected override void LoadingPlayer(IDK.ThirdPersonCamera camera)
        {
            //update camera
            IDK.Vector3 pos = new IDK.Vector3(0, 10, 0);

            IDK.Vector3 eyepos = new IDK.Vector3(pos.x - 15.0f, pos.y + 10.0f, pos.z);
            camera.LookAt(eyepos, pos, new IDK.Vector3(0.0f, 1.0f, 0.0f));
            camera.LookAt(pos);

            CameraObserver = new Game.Observer(camera, pos);
            GameScene.AddEntity(CameraObserver);
            {
                Game.GameAction.PlayerMoveAction plAction = new Game.GameAction.PlayerMoveAction(Game.GameAction.PlayerMoveAction.State.Forward);
                Game.CommonAction.ActionUpDownControlKeyboard plActionCtrl =
                    new Game.CommonAction.ActionUpDownControlKeyboard(new Game.Events.UserInput(Game.Events.UserInput.Key.D), plAction);
                GameScene.ActionManager.InputSubscriber.Add(plActionCtrl);

                plAction.Add(CameraObserver);
            }

            {
                Game.GameAction.PlayerMoveAction plAction = new Game.GameAction.PlayerMoveAction(Game.GameAction.PlayerMoveAction.State.Backward);
                Game.CommonAction.ActionUpDownControlKeyboard plActionCtrl =
                    new Game.CommonAction.ActionUpDownControlKeyboard(new Game.Events.UserInput(Game.Events.UserInput.Key.A), plAction);
                GameScene.ActionManager.InputSubscriber.Add(plActionCtrl);

                plAction.Add(CameraObserver);
            }

            {
                Game.GameAction.PlayerMoveAction plAction = new Game.GameAction.PlayerMoveAction(Game.GameAction.PlayerMoveAction.State.TurnLeft);
                Game.CommonAction.ActionUpDownControlKeyboard plActionCtrl =
                    new Game.CommonAction.ActionUpDownControlKeyboard(new Game.Events.UserInput(Game.Events.UserInput.Key.W), plAction);
                GameScene.ActionManager.InputSubscriber.Add(plActionCtrl);

                plAction.Add(CameraObserver);
            }

            {
                Game.GameAction.PlayerMoveAction plAction = new Game.GameAction.PlayerMoveAction(Game.GameAction.PlayerMoveAction.State.TurnRight);
                Game.CommonAction.ActionUpDownControlKeyboard plActionCtrl =
                    new Game.CommonAction.ActionUpDownControlKeyboard(new Game.Events.UserInput(Game.Events.UserInput.Key.S), plAction);
                GameScene.ActionManager.InputSubscriber.Add(plActionCtrl);

                plAction.Add(CameraObserver);
            }
            {
                Game.GameAction.PlayerMoveAction plAction = new Game.GameAction.PlayerMoveAction(Game.GameAction.PlayerMoveAction.State.Boost);
                Game.CommonAction.ActionUpDownControlKeyboard plActionCtrl =
                    new Game.CommonAction.ActionUpDownControlKeyboard(new Game.Events.UserInput(Game.Events.UserInput.Key.Shift), plAction);
                GameScene.ActionManager.InputSubscriber.Add(plActionCtrl);

                plAction.Add(CameraObserver);
            }

            //loading game player
            base.LoadingPlayer(camera);
        }
    }
}
